In [1]:
drive_path = 'c:/'
import numpy as np
import pandas as pd
import os
import sys
import matplotlib.pyplot as plt
from scipy.stats import ks_2samp
from scipy.stats import anderson_ksamp
from scipy.stats import kruskal
from scipy.stats import variation
from scipy.stats import spearmanr
from scipy.stats import zscore
from scipy.stats import gaussian_kde
import seaborn as sns
%matplotlib
In [4]:
#Import data
comp=pd.read_csv('C:\Users\Annie\Documents\Data\Ca_Imaging\GoodFiles\\fullpeak.csv')
# del comp['Mouse']
comp_sorted=comp.reindex_axis(comp.mean().sort_values().index, axis=1)
comp_labels=pd.DataFrame(comp.Group)
tmp=[comp_labels,comp_sorted]
composite_full=pd.concat(tmp,axis=1)
In [8]:
composite_full
Out[8]:
In [9]:
#Calculate means and variance for each odor
Cctrl=composite_full[composite_full['Group']=='Control']
Cmean=pd.DataFrame(Cctrl.mean())
Cmean.columns=['Control Mean']
Cvar=pd.DataFrame(Cctrl.var())
Cvar.columns=['Control Variance']
M=composite_full[composite_full['Group']=='Mint']
Mmean=pd.DataFrame(M.mean())
Mmean.columns=['Mint Mean']
Mvar=pd.DataFrame(M.var())
Mvar.columns=['Mint Variance']
H=composite_full[composite_full['Group']=='Hexanal']
Hmean=pd.DataFrame(H.mean())
Hmean.columns=['Hexanal Mean']
Hvar=pd.DataFrame(H.var())
Hvar.columns=['Hexanal Variance']
#Concat
Ctmp=[Cmean,Cvar]
Mtmp=[Mmean,Mvar]
Htmp=[Hmean,Hvar]
CtrlDF=pd.concat(Ctmp,axis=1)
MDF=pd.concat(Mtmp,axis=1)
HDF=pd.concat(Htmp,axis=1)
final=[CtrlDF,MDF,HDF]
finaldf=pd.concat(final,axis=1)
In [10]:
finaldf=finaldf.reset_index(drop=True)
In [11]:
finaldf.head()
Out[11]:
In [17]:
sns.set(style="white", palette="muted", color_codes=True);
sns.set_context("talk", font_scale=1.8);
plt.figure(figsize=(35, 20));
sns.regplot(finaldf['Control Mean'],finaldf['Control Variance'],scatter_kws={"s": 175},color='r')
sns.regplot(finaldf['Mint Mean'],finaldf['Mint Variance'],scatter_kws={"s": 175},color='g')
sns.regplot(finaldf['Hexanal Mean'],finaldf['Hexanal Variance'],scatter_kws={"s": 175},color='b')
sns.despine()
plt.ylabel('Variance', fontsize=48);
plt.title('Mean vs. Variance', fontsize=55);
plt.xlabel('Mean', fontsize=48);
plt.legend(loc=2, prop={'size': 48});
In [7]:
finaldf['Control Mean']
Out[7]:
In [13]:
Ccellmean=Cctrl.mean(axis=1)
Ccellvar=Cctrl.var(axis=1)
Mcellmean=M.mean(axis=1)
Mcellvar=M.var(axis=1)
Hcellmean=H.mean(axis=1)
Hcellvar=H.var(axis=1)
In [14]:
#Concat
Ctemp=[Cctrl['Group'],Ccellmean,Ccellvar]
Mtemp=[M['Group'],Mcellmean,Mcellvar]
Htemp=[H['Group'],Hcellmean,Hcellvar]
CtrlcellDF=pd.concat(Ctemp,axis=1)
CtrlcellDF.columns=('Group','Mean','Variance')
McellDF=pd.concat(Mtemp,axis=1)
McellDF.columns=('Group','Mean','Variance')
HcellDF=pd.concat(Htemp,axis=1)
HcellDF.columns=('Group','Mean','Variance')
finalcell=[CtrlcellDF,McellDF,HcellDF]
finalcelldf=pd.concat(finalcell,axis=0)
In [15]:
sns.regplot('Mean','Variance',CtrlcellDF)
Out[15]:
In [18]:
sns.set(style="white", palette="muted", color_codes=True);
sns.set_context("talk", font_scale=1.8);
plt.figure(figsize=(30, 15));
sns.regplot('Mean','Variance',CtrlcellDF,scatter_kws={"s": 80},color='r',label='Control')
sns.regplot('Mean','Variance',McellDF,scatter_kws={"s": 80},color='g',label='Mint')
sns.regplot('Mean','Variance',HcellDF,scatter_kws={"s": 80},color='b',label='Hexanal')
sns.despine()
plt.ylabel('Variance', fontsize=48);
plt.title('Mean vs. Variance', fontsize=55);
plt.xlabel('Mean', fontsize=48);
plt.legend(loc=2, prop={'size': 48});
In [ ]: